/*=============================================================================
#     FileName: AacEncoder.h
#         Desc: 
#       Author: zhfayuan
#        Email: afst2012@outlook.com
#      Version: 0.0.1
#   LastChange: 2020-10-12 21:52:59
#      History:
=============================================================================*/

#ifndef __AAC_ENCODER_H__
#define __AAC_ENCODER_H__


#include <memory>
#include <vector>
#include <functional>
#ifdef __cplusplus
extern "C"
{
#endif
#include <aacenc_lib.h>
#ifdef __cplusplus
}
#endif

using namespace std;



class AacEncoder
{
    private:
        bool _initialize;
        uint8_t *_pcmBuffer;
        uint32_t _pcmBuffferLength;
        uint32_t _pcmBuffferedLength;

        uint8_t *_aacBuffer;
        uint32_t _aacBuffferLength;

        uint32_t _aacEncRate;
        uint32_t _pcmAudioBit;
        uint32_t _pcmAudioChannel;
        uint32_t _timeMsOfAudio;
        double  _timeMsPerSample;
    private:
        HANDLE_AACENCODER _handle;
    public:
        AacEncoder();
        virtual ~AacEncoder();
    public:
        void initialize(uint32_t rate,uint32_t bit,uint32_t channel);
        void encode(std::shared_ptr<std::vector<char>> &packet,uint32_t pkt_pts,std::function<void(std::shared_ptr<std::vector<char>>&packet,uint32_t pts_ms)> func);
};

#endif
